package com.hd.assistant.web.common.display;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.taobao.api.domain.ArticleUserSubscribe;

public class IsvOrderInfo {

	public static String ORDERMINING_ISV_ARTICLECODE = "FW_GOODS-1887386";
	public static String ORDERMINING_ISV_ARTICLECODE_TRY = "FW_GOODS-1887386-1";
	public static String ORDERMINING_ISV_ARTICLECODE_BASIC = "FW_GOODS-1887386-v2";
	
	List<ArticleUserSubscribe> articles = new ArrayList<ArticleUserSubscribe>();
	Map<String, ArticleUserSubscribe> articleUserMap = new HashMap<String, ArticleUserSubscribe>();
	
	public boolean containsArticle(String itemCode){
		return articleUserMap.containsKey(itemCode);
	}
	
	public List<ArticleUserSubscribe> getArticles() {
		return articles;
	}

	public void setArticles(List<ArticleUserSubscribe> articles) {
		this.articles = articles;
		if(articles != null){
			for(ArticleUserSubscribe a :articles){
				if(a.getItemCode().equals(ORDERMINING_ISV_ARTICLECODE_TRY)){
					a.setDisplay("试用版");
				}
				if(a.getItemCode().equals(ORDERMINING_ISV_ARTICLECODE_BASIC)){
					a.setDisplay("基础版");
				}
				articleUserMap.put(a.getItemCode(), a);
			}
			
		}
	}

	public Map<String, ArticleUserSubscribe> getArticleUserMap() {
		return articleUserMap;
	}

	public void setArticleUserMap(Map<String, ArticleUserSubscribe> articleUserMap) {
		this.articleUserMap = articleUserMap;
	}

	public ArticleUserSubscribe getOrderMiningArticle(){
		if(articleUserMap.containsKey(ORDERMINING_ISV_ARTICLECODE_BASIC))
			return articleUserMap.get(ORDERMINING_ISV_ARTICLECODE_BASIC);
		if(articleUserMap.containsKey(ORDERMINING_ISV_ARTICLECODE_TRY))
			return articleUserMap.get(ORDERMINING_ISV_ARTICLECODE_TRY);
		return null;
	}
	
	public boolean isOrderminingTry(){
		ArticleUserSubscribe a = getOrderMiningArticle();
		if(a!=null){
			return a.getItemCode().equals(ORDERMINING_ISV_ARTICLECODE_TRY);
		}
		return false;
	}
}
